﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.BaseInfoServiceRef;

    public class Pack : BasePage
    {
        protected Button btnCopy;
        protected Button btnDelete;
        protected Button btnGoBack;
        protected Button btnNew;
        protected Button btnSave;
        protected CheckBox chkCartonize01;
        protected CheckBox chkCartonize02;
        protected CheckBox chkCartonize03;
        protected CheckBox chkCartonize04;
        protected CheckBox chkCartonize05;
        protected CheckBox chkCartonize06;
        protected CheckBox chkCartonize07;
        protected CheckBox chkCartonize08;
        protected CheckBox chkCartonize09;
        protected CheckBox chkInLabelUnit01;
        protected CheckBox chkInLabelUnit02;
        protected CheckBox chkInLabelUnit03;
        protected CheckBox chkInLabelUnit04;
        protected CheckBox chkInLabelUnit05;
        protected CheckBox chkInLabelUnit06;
        protected CheckBox chkInLabelUnit07;
        protected CheckBox chkInLabelUnit08;
        protected CheckBox chkInLabelUnit09;
        protected CheckBox chkIsActive;
        protected CheckBox chkOutLabelUnit01;
        protected CheckBox chkOutLabelUnit02;
        protected CheckBox chkOutLabelUnit03;
        protected CheckBox chkOutLabelUnit04;
        protected CheckBox chkOutLabelUnit05;
        protected CheckBox chkOutLabelUnit06;
        protected CheckBox chkOutLabelUnit07;
        protected CheckBox chkOutLabelUnit08;
        protected CheckBox chkOutLabelUnit09;
        protected CheckBox chkReplenish01;
        protected CheckBox chkReplenish02;
        protected CheckBox chkReplenish03;
        protected CheckBox chkReplenish04;
        protected CheckBox chkReplenish05;
        protected CheckBox chkReplenish06;
        protected CheckBox chkReplenish07;
        protected CheckBox chkReplenish08;
        protected CheckBox chkReplenish09;
        protected CheckBox chkSysCreated;
        protected DropDownList ddlFieldUom01;
        protected DropDownList ddlFieldUom02;
        protected DropDownList ddlFieldUom03;
        protected DropDownList ddlFieldUom04;
        protected DropDownList ddlFieldUom05;
        protected DropDownList ddlFieldUom06;
        protected DropDownList ddlFieldUom07;
        protected DropDownList ddlFieldUom08;
        protected DropDownList ddlFieldUom09;
        protected HtmlForm F2071;
        protected HtmlInputHidden hdnFrom;
        protected Label Label1;
        protected Label Label2;
        protected Label Label3;
        protected Label Label4;
        protected Label Label5;
        protected Label lblCartonize;
        protected Label lblCasePerLayer;
        protected Label lblCube01;
        protected Label lblCube02;
        protected Label lblCube03;
        protected Label lblCube04;
        protected Label lblDescr;
        protected Label lblFieldName01;
        protected Label lblFieldName02;
        protected Label lblFieldName03;
        protected Label lblFieldName04;
        protected Label lblFieldName05;
        protected Label lblFieldName06;
        protected Label lblFieldName07;
        protected Label lblFieldName08;
        protected Label lblFieldName09;
        protected Label lblHeight;
        protected Label lblInLabelUnit;
        protected Label lblLength01;
        protected Label lblLength02;
        protected Label lblLength03;
        protected Label lblLength04;
        protected Label lblLength05;
        protected Label lblLength06;
        protected Label lblMsg;
        protected Label lblOutLabelUnit;
        protected Label lblPack;
        protected Label lblPackID;
        protected Label lblPalletHeight;
        protected Label lblPalletLayer;
        protected Label lblPalletLength;
        protected Label lblPalletWidth;
        protected Label lblQty;
        protected Label lblQty01;
        protected Label lblQty02;
        protected Label lblQty03;
        protected Label lblQty04;
        protected Label lblQty05;
        protected Label lblQty06;
        protected Label lblReplenish;
        protected Label lblUom;
        protected Label lblUom01;
        protected Label lblUom02;
        protected Label lblUom03;
        protected Label lblUom04;
        protected Label lblUom05;
        protected Label lblUom06;
        protected Label lblWidth01;
        protected Label lblWidth02;
        protected Label lblWidth03;
        protected Label lblWidth04;
        protected Label lblWidth05;
        protected Label lblWidth06;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected Label one3;
        protected Label one4;
        protected Label one5;
        protected Label one6;
        protected Label one7;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCasePerLayer;
        protected TextBox txtCube01;
        protected TextBox txtCube02;
        protected TextBox txtCube03;
        protected TextBox txtCube04;
        protected TextBox txtFieldValue01;
        protected TextBox txtFieldValue02;
        protected TextBox txtFieldValue03;
        protected TextBox txtFieldValue04;
        protected TextBox txtFieldValue05;
        protected TextBox txtFieldValue06;
        protected TextBox txtFieldValue07;
        protected TextBox txtFieldValue08;
        protected TextBox txtFieldValue09;
        protected TextBox txtHeight01;
        protected TextBox txtHeight02;
        protected TextBox txtHeight03;
        protected TextBox txtHeight04;
        protected TextBox txtHeight05;
        protected TextBox txtHeight06;
        protected TextBox txtLength01;
        protected TextBox txtLength02;
        protected TextBox txtLength03;
        protected TextBox txtLength04;
        protected TextBox txtLength05;
        protected TextBox txtLength06;
        protected TextBox txtPackDescr;
        protected TextBox txtPackID;
        protected TextBox txtPalletHeight;
        protected TextBox txtPalletLayer;
        protected TextBox txtPalletLength;
        protected TextBox txtPalletWidth;
        protected TextBox txtQty01;
        protected TextBox txtQty02;
        protected TextBox txtQty03;
        protected TextBox txtQty04;
        protected TextBox txtQty05;
        protected TextBox txtQty06;
        protected TextBox txtUom01;
        protected TextBox txtUom02;
        protected TextBox txtUom03;
        protected TextBox txtUom04;
        protected TextBox txtUom05;
        protected TextBox txtUom06;
        protected TextBox txtWidth01;
        protected TextBox txtWidth02;
        protected TextBox txtWidth03;
        protected TextBox txtWidth04;
        protected TextBox txtWidth05;
        protected TextBox txtWidth06;
        protected UpdatePanel up1;

        private void BindData2UomDDL(DropDownList ddl, DataTable dt)
        {
            ddl.DataSource = dt;
            ddl.DataTextField = "UOM_DESCR";
            ddl.DataValueField = "UOM_ID";
            ddl.DataBind();
        }

        protected void btnCopy_Click(object sender, EventArgs e)
        {
            this.txtPackID.Text = "";
            this.txtPackID.Enabled = true;
            this.chkSysCreated.Checked = false;
            base.DataEntityViewState = null;
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.chkSysCreated.Checked)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("C011");
            }
            else if (!string.IsNullOrEmpty(this.txtPackID.Text.Trim()))
            {
                try
                {
                    List<string> packID = new List<string> {
                        this.txtPackID.Text.Trim()
                    };
                    this.lblMsg.Text = BaseInfoServiceClientProxy.GetInstance().Delete(packID, "PACK") + base.GetGlobalMsgResource("C006");
                    this.btnSave.Enabled = false;
                    this.btnDelete.Enabled = false;
                    this.btnCopy.Enabled = false;
                    base.DataEntityViewState = null;
                }
                catch (Exception ex)
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("C007") + ex.Message;
                }
            }
        }

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            switch (this.hdnFrom.Value)
            {
                case "query":
                    base.Response.Redirect("PackQuery.aspx", false);
                    break;

                case "list":
                    base.Response.Redirect("PackList.aspx?from=edit", false);
                    break;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtPackID.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F2220_001");
                }
                else
                {
                    for (int i = 1; i < 10; i++)
                    {
                        if ((!string.IsNullOrEmpty(((TextBox) this.Page.FindControl("txtFieldValue0" + i.ToString())).Text) && (decimal.Parse(((TextBox) this.Page.FindControl("txtFieldValue0" + i.ToString())).Text) != 0M)) && string.IsNullOrEmpty(((DropDownList) this.Page.FindControl("ddlFieldUom0" + i.ToString())).SelectedValue))
                        {
                            this.lblMsg.Text = base.GetGlobalMsgResource("F2220_002");
                            return;
                        }
                    }
                    if (base.DataEntityViewState != null)
                    {
                        this.UpdatePackInfo();
                    }
                    else
                    {
                        this.InsertPackInfo();
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message.ToString();
            }
        }

        private PackInfo GetPackInfoFromForm(PackInfo packInfo)
        {
            packInfo.PackID = this.txtPackID.Text.Trim();
            packInfo.Description = this.txtPackDescr.Text.Trim();
            packInfo.IsActive = this.chkIsActive.Checked ? "Y" : "N";
            packInfo.SystemCreated = this.chkSysCreated.Checked ? "Y" : "N";
            packInfo.Qty = float.Parse((this.txtFieldValue01.Text.Trim() == "") ? "0" : this.txtFieldValue01.Text.Trim());
            packInfo.PackUom1 = this.ddlFieldUom01.SelectedValue;
            packInfo.LengthUom1 = float.Parse((this.txtLength01.Text.Trim() == "") ? "0" : this.txtLength01.Text.Trim());
            packInfo.WidthUom1 = float.Parse((this.txtWidth01.Text.Trim() == "") ? "0" : this.txtWidth01.Text.Trim());
            packInfo.HeightUom1 = float.Parse((this.txtHeight01.Text.Trim() == "") ? "0" : this.txtHeight01.Text.Trim());
            packInfo.CubeUom1 = float.Parse((this.txtCube01.Text.Trim() == "") ? "0" : this.txtHeight01.Text.Trim());
            packInfo.IsCartonizeUom1 = this.chkCartonize01.Checked ? "Y" : "N";
            packInfo.IsReplenishUom1 = this.chkReplenish01.Checked ? "Y" : "N";
            packInfo.IsInLabelUom1 = this.chkInLabelUnit01.Checked ? "Y" : "N";
            packInfo.IsOutLabelUom1 = this.chkOutLabelUnit01.Checked ? "Y" : "N";
            packInfo.InnerPack = float.Parse((this.txtFieldValue02.Text.Trim() == "") ? "0" : this.txtFieldValue02.Text.Trim());
            packInfo.PackUom2 = this.ddlFieldUom02.SelectedValue;
            packInfo.LengthUom2 = float.Parse((this.txtLength02.Text.Trim() == "") ? "0" : this.txtLength02.Text.Trim());
            packInfo.WidthUom2 = float.Parse((this.txtWidth02.Text.Trim() == "") ? "0" : this.txtWidth02.Text.Trim());
            packInfo.HeightUom2 = float.Parse((this.txtHeight02.Text.Trim() == "") ? "0" : this.txtHeight02.Text.Trim());
            packInfo.CubeUom2 = float.Parse((this.txtCube02.Text.Trim() == "") ? "0" : this.txtHeight01.Text.Trim());
            packInfo.IsCartonizeUom2 = this.chkCartonize02.Checked ? "Y" : "N";
            packInfo.IsReplenishUom2 = this.chkReplenish02.Checked ? "Y" : "N";
            packInfo.IsInLabelUom2 = this.chkInLabelUnit02.Checked ? "Y" : "N";
            packInfo.IsOutLabelUom2 = this.chkOutLabelUnit02.Checked ? "Y" : "N";
            packInfo.CaseCnt = float.Parse((this.txtFieldValue03.Text.Trim() == "") ? "0" : this.txtFieldValue03.Text.Trim());
            packInfo.PackUom3 = this.ddlFieldUom03.SelectedValue;
            packInfo.LengthUom3 = float.Parse((this.txtLength03.Text.Trim() == "") ? "0" : this.txtLength03.Text.Trim());
            packInfo.WidthUom3 = float.Parse((this.txtWidth03.Text.Trim() == "") ? "0" : this.txtWidth03.Text.Trim());
            packInfo.HeightUom3 = float.Parse((this.txtHeight03.Text.Trim() == "") ? "0" : this.txtHeight03.Text.Trim());
            packInfo.CubeUom3 = float.Parse((this.txtCube03.Text.Trim() == "") ? "0" : this.txtHeight01.Text.Trim());
            packInfo.IsCartonizeUom3 = this.chkCartonize03.Checked ? "Y" : "N";
            packInfo.IsReplenishUom3 = this.chkReplenish03.Checked ? "Y" : "N";
            packInfo.IsInLabelUom3 = this.chkInLabelUnit03.Checked ? "Y" : "N";
            packInfo.IsOutLabelUom3 = this.chkOutLabelUnit03.Checked ? "Y" : "N";
            packInfo.Pallet = float.Parse((this.txtFieldValue04.Text.Trim() == "") ? "0" : this.txtFieldValue04.Text.Trim());
            packInfo.PackUom4 = this.ddlFieldUom04.SelectedValue;
            packInfo.LengthUom4 = float.Parse((this.txtLength04.Text.Trim() == "") ? "0" : this.txtLength04.Text.Trim());
            packInfo.WidthUom4 = float.Parse((this.txtWidth04.Text.Trim() == "") ? "0" : this.txtWidth04.Text.Trim());
            packInfo.HeightUom4 = float.Parse((this.txtHeight04.Text.Trim() == "") ? "0" : this.txtHeight04.Text.Trim());
            packInfo.CubeUom4 = float.Parse((this.txtCube04.Text.Trim() == "") ? "0" : this.txtHeight01.Text.Trim());
            packInfo.IsCartonizeUom4 = this.chkCartonize04.Checked ? "Y" : "N";
            packInfo.IsReplenishUom4 = this.chkReplenish04.Checked ? "Y" : "N";
            packInfo.IsInLabelUom4 = this.chkInLabelUnit04.Checked ? "Y" : "N";
            packInfo.IsOutLabelUom4 = this.chkOutLabelUnit04.Checked ? "Y" : "N";
            packInfo.PalletTi = decimal.Parse((this.txtCasePerLayer.Text.Trim() == "") ? "0" : this.txtCasePerLayer.Text.Trim());
            packInfo.PalletHi = decimal.Parse((this.txtPalletLayer.Text.Trim() == "") ? "0" : this.txtPalletLayer.Text.Trim());
            packInfo.PalletWoodLength = float.Parse((this.txtPalletLength.Text.Trim() == "") ? "0" : this.txtPalletLength.Text.Trim());
            packInfo.PalletWoodWidth = float.Parse((this.txtPalletWidth.Text.Trim() == "") ? "0" : this.txtPalletWidth.Text.Trim());
            packInfo.PalletWoodHeight = float.Parse((this.txtPalletHeight.Text.Trim() == "") ? "0" : this.txtPalletHeight.Text.Trim());
            packInfo.Cube = float.Parse((this.txtFieldValue05.Text.Trim() == "") ? "0" : this.txtFieldValue05.Text.Trim());
            packInfo.PackUom5 = this.ddlFieldUom05.SelectedValue;
            packInfo.GrossWgt = float.Parse((this.txtFieldValue06.Text.Trim() == "") ? "0" : this.txtFieldValue06.Text.Trim());
            packInfo.PackUom6 = this.ddlFieldUom06.SelectedValue;
            packInfo.NetWgt = float.Parse((this.txtFieldValue07.Text.Trim() == "") ? "0" : this.txtFieldValue07.Text.Trim());
            packInfo.PackUom7 = this.ddlFieldUom07.SelectedValue;
            packInfo.OtherUnit1 = float.Parse((this.txtFieldValue08.Text.Trim() == "") ? "0" : this.txtFieldValue08.Text.Trim());
            packInfo.PackUom8 = this.ddlFieldUom08.SelectedValue;
            packInfo.LengthUom8 = float.Parse((this.txtLength05.Text.Trim() == "") ? "0" : this.txtLength05.Text.Trim());
            packInfo.WidthUom8 = float.Parse((this.txtWidth05.Text.Trim() == "") ? "0" : this.txtWidth05.Text.Trim());
            packInfo.HeightUom8 = float.Parse((this.txtHeight05.Text.Trim() == "") ? "0" : this.txtHeight05.Text.Trim());
            packInfo.IsCartonizeUom8 = this.chkCartonize08.Checked ? "Y" : "N";
            packInfo.IsReplenishUom8 = this.chkReplenish08.Checked ? "Y" : "N";
            packInfo.IsInLabelUom8 = this.chkInLabelUnit08.Checked ? "Y" : "N";
            packInfo.IsOutLabelUom8 = this.chkOutLabelUnit08.Checked ? "Y" : "N";
            packInfo.OtherUnit2 = float.Parse((this.txtFieldValue09.Text.Trim() == "") ? "0" : this.txtFieldValue09.Text.Trim());
            packInfo.PackUom9 = this.ddlFieldUom09.SelectedValue;
            packInfo.LengthUom9 = float.Parse((this.txtLength06.Text.Trim() == "") ? "0" : this.txtLength06.Text.Trim());
            packInfo.WidthUom9 = float.Parse((this.txtWidth06.Text.Trim() == "") ? "0" : this.txtWidth06.Text.Trim());
            packInfo.HeightUom9 = float.Parse((this.txtHeight06.Text.Trim() == "") ? "0" : this.txtHeight06.Text.Trim());
            packInfo.IsCartonizeUom9 = this.chkCartonize09.Checked ? "Y" : "N";
            packInfo.IsReplenishUom9 = this.chkReplenish09.Checked ? "Y" : "N";
            packInfo.IsInLabelUom9 = this.chkInLabelUnit09.Checked ? "Y" : "N";
            packInfo.IsOutLabelUom9 = this.chkOutLabelUnit09.Checked ? "Y" : "N";
            return packInfo;
        }

        private void InitUomDDL()
        {
            int i;
            UomQueryEntity uomQuery = new UomQueryEntity {
                IsActive = " LIKE '%Y%' ",
                IsGetAll = true
            };
            DataTable dt = BaseInfoServiceClientProxy.GetInstance().GetInfoByQueryEntity(uomQuery, "UOM").Tables[0];
            DataRow[] quantityDR = dt.Select("UOM_TYPE = 'Quantity'");
            DataTable tempDT = dt.Clone();
            DataRow tempDR = tempDT.NewRow();
            tempDT.Rows.Add(tempDR);
            for (i = 0; i < quantityDR.Length; i++)
            {
                tempDT.ImportRow(quantityDR[i]);
            }
            this.BindData2UomDDL(this.ddlFieldUom01, tempDT);
            this.BindData2UomDDL(this.ddlFieldUom02, tempDT);
            DataRow[] packageDR = dt.Select("UOM_TYPE = 'Package'");
            tempDT.Clear();
            tempDT.Rows.Add(tempDR);
            for (i = 0; i < packageDR.Length; i++)
            {
                tempDT.ImportRow(packageDR[i]);
            }
            this.BindData2UomDDL(this.ddlFieldUom03, tempDT);
            this.BindData2UomDDL(this.ddlFieldUom04, tempDT);
            DataRow[] volumeDR = dt.Select("UOM_TYPE = 'Volume'");
            tempDT.Clear();
            tempDT.Rows.Add(tempDR);
            for (i = 0; i < volumeDR.Length; i++)
            {
                tempDT.ImportRow(volumeDR[i]);
            }
            this.BindData2UomDDL(this.ddlFieldUom05, tempDT);
            DataRow[] weightDR = dt.Select("UOM_TYPE = 'Weight'");
            tempDT.Clear();
            tempDT.Rows.Add(tempDR);
            for (i = 0; i < weightDR.Length; i++)
            {
                tempDT.ImportRow(weightDR[i]);
            }
            this.BindData2UomDDL(this.ddlFieldUom06, tempDT);
            this.BindData2UomDDL(this.ddlFieldUom07, tempDT);
            DataRow[] lengthDR = dt.Select("UOM_TYPE = 'Dims'");
            tempDT.Clear();
            tempDT.Rows.Add(tempDR);
            for (i = 0; i < lengthDR.Length; i++)
            {
                tempDT.ImportRow(lengthDR[i]);
            }
            this.BindData2UomDDL(this.ddlFieldUom08, tempDT);
            this.BindData2UomDDL(this.ddlFieldUom09, tempDT);
        }

        private void InsertPackInfo()
        {
            try
            {
                PackInfo packInfo = new PackInfo();
                packInfo = this.GetPackInfoFromForm(packInfo);
                packInfo.CreatedBy = base.UserInfo.UserID;
                this.lblMsg.Text = BaseInfoServiceClientProxy.GetInstance().Insert(packInfo, "PACK") + base.GetGlobalMsgResource("C004");
                base.DataEntityViewState = packInfo;
                this.txtPackID.Enabled = false;
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("C005") + ex.Message;
            }
        }

        private void LoadData()
        {
            this.InitUomDDL();
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                this.SetPackInfo2Form();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                this.hdnFrom.Value = base.Request.QueryString["from"].ToString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        private void SetPackInfo2Form()
        {
            try
            {
                string packID = base.Request.QueryString["ID"].ToString();
                PackInfo packInfo = BaseInfoServiceClientProxy.GetInstance().GetInfoByID(packID, "PACK") as PackInfo;
                base.DataEntityViewState = packInfo;
                if (packInfo != null)
                {
                    this.txtPackID.Text = packInfo.PackID;
                    this.txtPackDescr.Text = packInfo.Description;
                    this.chkIsActive.Checked = packInfo.IsActive == "Y";
                    this.chkSysCreated.Checked = packInfo.SystemCreated == "Y";
                    this.txtFieldValue01.Text = base.GetPreferenceDigit(packInfo.Qty);
                    this.ddlFieldUom01.SelectedValue = packInfo.PackUom1;
                    this.txtLength01.Text = base.GetPreferenceDigit(packInfo.LengthUom1);
                    this.txtWidth01.Text = base.GetPreferenceDigit(packInfo.WidthUom1);
                    this.txtHeight01.Text = base.GetPreferenceDigit(packInfo.HeightUom1);
                    this.txtCube01.Text = base.GetPreferenceDigit(packInfo.CubeUom1);
                    this.chkCartonize01.Checked = packInfo.IsCartonizeUom1 == "Y";
                    this.chkReplenish01.Checked = packInfo.IsReplenishUom1 == "Y";
                    this.chkInLabelUnit01.Checked = packInfo.IsInLabelUom1 == "Y";
                    this.chkOutLabelUnit01.Checked = packInfo.IsOutLabelUom1 == "Y";
                    this.txtFieldValue02.Text = base.GetPreferenceDigit(packInfo.InnerPack);
                    this.ddlFieldUom02.SelectedValue = packInfo.PackUom2;
                    this.txtLength02.Text = base.GetPreferenceDigit(packInfo.LengthUom2);
                    this.txtWidth02.Text = base.GetPreferenceDigit(packInfo.WidthUom2);
                    this.txtHeight02.Text = base.GetPreferenceDigit(packInfo.HeightUom2);
                    this.txtCube02.Text = base.GetPreferenceDigit(packInfo.CubeUom2);
                    this.chkCartonize02.Checked = packInfo.IsCartonizeUom2 == "Y";
                    this.chkReplenish02.Checked = packInfo.IsReplenishUom2 == "Y";
                    this.chkInLabelUnit02.Checked = packInfo.IsInLabelUom2 == "Y";
                    this.chkOutLabelUnit02.Checked = packInfo.IsOutLabelUom2 == "Y";
                    this.txtFieldValue03.Text = base.GetPreferenceDigit(packInfo.CaseCnt);
                    this.ddlFieldUom03.SelectedValue = packInfo.PackUom3;
                    this.txtLength03.Text = base.GetPreferenceDigit(packInfo.LengthUom3);
                    this.txtWidth03.Text = base.GetPreferenceDigit(packInfo.WidthUom3);
                    this.txtHeight03.Text = base.GetPreferenceDigit(packInfo.HeightUom3);
                    this.txtCube03.Text = base.GetPreferenceDigit(packInfo.CubeUom3);
                    this.chkCartonize03.Checked = packInfo.IsCartonizeUom3 == "Y";
                    this.chkReplenish03.Checked = packInfo.IsReplenishUom3 == "Y";
                    this.chkInLabelUnit03.Checked = packInfo.IsInLabelUom3 == "Y";
                    this.chkOutLabelUnit03.Checked = packInfo.IsOutLabelUom3 == "Y";
                    this.txtFieldValue04.Text = base.GetPreferenceDigit(packInfo.Pallet);
                    this.ddlFieldUom04.SelectedValue = packInfo.PackUom4;
                    this.txtLength04.Text = base.GetPreferenceDigit(packInfo.LengthUom4);
                    this.txtWidth04.Text = base.GetPreferenceDigit(packInfo.WidthUom4);
                    this.txtHeight04.Text = base.GetPreferenceDigit(packInfo.HeightUom4);
                    this.txtCube04.Text = base.GetPreferenceDigit(packInfo.CubeUom4);
                    this.chkCartonize04.Checked = packInfo.IsCartonizeUom4 == "Y";
                    this.chkReplenish04.Checked = packInfo.IsReplenishUom4 == "Y";
                    this.chkInLabelUnit04.Checked = packInfo.IsInLabelUom4 == "Y";
                    this.chkOutLabelUnit04.Checked = packInfo.IsOutLabelUom4 == "Y";
                    this.txtCasePerLayer.Text = base.GetPreferenceDigit(packInfo.PalletTi);
                    this.txtPalletLayer.Text = base.GetPreferenceDigit(packInfo.PalletHi);
                    this.txtPalletLength.Text = base.GetPreferenceDigit(packInfo.PalletWoodLength);
                    this.txtPalletWidth.Text = base.GetPreferenceDigit(packInfo.PalletWoodWidth);
                    this.txtPalletHeight.Text = base.GetPreferenceDigit(packInfo.PalletWoodHeight);
                    this.txtFieldValue05.Text = base.GetPreferenceDigit(packInfo.Cube);
                    this.ddlFieldUom05.SelectedValue = packInfo.PackUom5;
                    this.txtFieldValue06.Text = base.GetPreferenceDigit(packInfo.GrossWgt);
                    this.ddlFieldUom06.SelectedValue = packInfo.PackUom6;
                    this.txtFieldValue07.Text = base.GetPreferenceDigit(packInfo.NetWgt);
                    this.ddlFieldUom07.SelectedValue = packInfo.PackUom7;
                    this.txtFieldValue08.Text = base.GetPreferenceDigit(packInfo.OtherUnit1);
                    this.ddlFieldUom08.SelectedValue = packInfo.PackUom8;
                    this.txtLength05.Text = base.GetPreferenceDigit(packInfo.LengthUom8);
                    this.txtWidth05.Text = base.GetPreferenceDigit(packInfo.WidthUom8);
                    this.txtHeight05.Text = base.GetPreferenceDigit(packInfo.HeightUom8);
                    this.chkCartonize08.Checked = packInfo.IsCartonizeUom8 == "Y";
                    this.chkReplenish08.Checked = packInfo.IsReplenishUom8 == "Y";
                    this.chkInLabelUnit08.Checked = packInfo.IsInLabelUom8 == "Y";
                    this.chkOutLabelUnit08.Checked = packInfo.IsOutLabelUom8 == "Y";
                    this.txtFieldValue09.Text = base.GetPreferenceDigit(packInfo.OtherUnit2);
                    this.ddlFieldUom09.SelectedValue = packInfo.PackUom9;
                    this.txtLength06.Text = base.GetPreferenceDigit(packInfo.LengthUom9);
                    this.txtWidth06.Text = base.GetPreferenceDigit(packInfo.WidthUom9);
                    this.txtHeight06.Text = base.GetPreferenceDigit(packInfo.HeightUom9);
                    this.chkCartonize09.Checked = packInfo.IsCartonizeUom9 == "Y";
                    this.chkReplenish09.Checked = packInfo.IsReplenishUom9 == "Y";
                    this.chkInLabelUnit09.Checked = packInfo.IsInLabelUom9 == "Y";
                    this.chkOutLabelUnit09.Checked = packInfo.IsOutLabelUom9 == "Y";
                    this.txtPackID.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }

        private void UpdatePackInfo()
        {
            try
            {
                PackInfo packInfo = base.DataEntityViewState as PackInfo;
                packInfo = this.GetPackInfoFromForm(packInfo);
                packInfo.UpdatedBy = base.UserInfo.UserID;
                this.lblMsg.Text = BaseInfoServiceClientProxy.GetInstance().Update(packInfo, "PACK") + base.GetGlobalMsgResource("C002");
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("C003") + ex.Message;
            }
        }
    }
}

